home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / mallcrawl.swf / scripts / __Packages / MallCrawl.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  5.8 KB  |  196 lines

  1. class MallCrawl extends MovieClip
  2. {
  3.    var paused;
  4.    var twinsArray;
  5.    var upEscalators;
  6.    var downEscalators;
  7.    var randomTwinSpots;
  8.    var randomPowerSpots;
  9.    var randomBrokenSpots;
  10.    var startPos;
  11.    var Background;
  12.    var level;
  13.    var FOLLOWER_DISTANCE = 15;
  14.    var MAX_LEVELS = 3;
  15.    var twinNames = new Array("Cloe","Jade","Nita","Nora","Sasha","Yasmin");
  16.    function MallCrawl()
  17.    {
  18.       super();
  19.       this._name = "MallCrawl";
  20.       _global[this._name] = this;
  21.       this.paused = false;
  22.       this.twinsArray = new Array();
  23.       this.upEscalators = new Array();
  24.       this.downEscalators = new Array();
  25.       this.randomTwinSpots = new Array();
  26.       this.randomPowerSpots = new Array();
  27.       this.randomBrokenSpots = new Array();
  28.       this.startPos = {x:this._x,y:this._y};
  29.    }
  30.    function gameOver()
  31.    {
  32.       _global.Footer.stopTimer();
  33.       this.resetStage();
  34.       this.gotoAndStop("game_over");
  35.    }
  36.    function generateTwins(amt)
  37.    {
  38.       var _loc3_ = new Array();
  39.       var _loc5_ = 0;
  40.       while(_loc5_ < this.twinNames.length)
  41.       {
  42.          _loc3_.push(this.twinNames[_loc5_]);
  43.          _loc5_ = _loc5_ + 1;
  44.       }
  45.       _loc5_ = 0;
  46.       while(_loc5_ < _loc3_.length)
  47.       {
  48.          if(_loc3_[_loc5_] == _global.char_selected)
  49.          {
  50.             _loc3_.popById(_loc5_);
  51.             break;
  52.          }
  53.          _loc5_ = _loc5_ + 1;
  54.       }
  55.       var _loc7_ = new Array();
  56.       _loc5_ = 0;
  57.       while(_loc5_ < amt)
  58.       {
  59.          var _loc6_ = random(_loc3_.length - 1);
  60.          var _loc4_ = _loc3_.popById(_loc6_);
  61.          _loc7_.push(_loc4_);
  62.          this.Background.attachMovie(_loc4_ + "Twin",_loc4_ + "Twin",this.Background.getNextHighestDepth());
  63.          _loc5_ = _loc5_ + 1;
  64.       }
  65.       this.Background.attachMovie("PuppyTwin","PuppyTwin",this.Background.getNextHighestDepth());
  66.       return _loc7_;
  67.    }
  68.    function generatePowerItems()
  69.    {
  70.       var _loc3_ = new Array();
  71.       var _loc2_ = 0;
  72.       while(_loc2_ < this.randomPowerSpots.length)
  73.       {
  74.          _loc3_.push(this.randomPowerSpots[_loc2_]);
  75.          _loc2_ = _loc2_ + 1;
  76.       }
  77.       var _loc5_ = random(3);
  78.       var _loc4_ = _loc3_.popById(random(_loc3_.length - 1));
  79.       switch(_loc5_)
  80.       {
  81.          case 0:
  82.             this.Background.attachMovie("SkateBoard","SkateBoard",this.Background.getNextHighestDepth(),{_x:_loc4_._x,_y:_loc4_._y});
  83.             break;
  84.          case 1:
  85.             this.Background.attachMovie("Trike","Trike",this.Background.getNextHighestDepth(),{_x:_loc4_._x,_y:_loc4_._y});
  86.             break;
  87.          case 2:
  88.             this.Background.attachMovie("Wheeler","Wheeler",this.Background.getNextHighestDepth(),{_x:_loc4_._x,_y:_loc4_._y});
  89.       }
  90.       _loc4_ = _loc3_.popById(random(_loc3_.length - 1));
  91.       this.Background.attachMovie("Bottle","Bottle",this.Background.getNextHighestDepth(),{_x:_loc4_._x,_y:_loc4_._y});
  92.       _loc4_ = _loc3_.popById(random(_loc3_.length - 1));
  93.       this.Background.attachMovie("Guitar","Guitar",this.Background.getNextHighestDepth(),{_x:_loc4_._x,_y:_loc4_._y});
  94.    }
  95.    function generateBrokenItems(amt)
  96.    {
  97.       var _loc6_ = new Array("BrokenCar","BrokenMirror","BrokenBrush");
  98.       var _loc5_ = new Array();
  99.       var _loc4_ = 0;
  100.       while(_loc4_ < this.randomBrokenSpots.length)
  101.       {
  102.          _loc5_.push(this.randomBrokenSpots[_loc4_]);
  103.          _loc4_ = _loc4_ + 1;
  104.       }
  105.       var _loc10_ = random(3);
  106.       _loc4_ = 0;
  107.       while(_loc4_ < amt)
  108.       {
  109.          var _loc2_ = _loc5_.popById(random(_loc5_.length - 1));
  110.          var _loc3_ = _loc6_.popById(random(_loc6_.length - 1));
  111.          this.Background.attachMovie(_loc3_,_loc3_,this.Background.getNextHighestDepth(),{_x:_loc2_._x,_y:_loc2_._y});
  112.          _loc4_ = _loc4_ + 1;
  113.       }
  114.    }
  115.    function nextLevel()
  116.    {
  117.       this.level += 1;
  118.       _global.Footer.setLevel();
  119.       _global.Footer.addScore(500 + _global.Footer.time / 1000);
  120.       _global.Footer.setTimer(180);
  121.       _global.Footer.startTimer();
  122.       this.twinsArray = new Array();
  123.       this.upEscalators = new Array();
  124.       this.downEscalators = new Array();
  125.       this.randomTwinSpots = new Array();
  126.       this.randomPowerSpots = new Array();
  127.       this.randomBrokenSpots = new Array();
  128.       this.gotoAndPlay("level" + this.level);
  129.    }
  130.    function outOfTime()
  131.    {
  132.       _global.Footer.stopTimer();
  133.       this.resetStage();
  134.       this.gotoAndStop("no_time");
  135.    }
  136.    function pause()
  137.    {
  138.       if(!this.paused)
  139.       {
  140.          this.paused = true;
  141.       }
  142.       else
  143.       {
  144.          this.paused = false;
  145.       }
  146.    }
  147.    function popUp(twin_Names)
  148.    {
  149.       this.pause();
  150.       this.attachMovie("PopUp","PopUp",1,{twin_Names:twin_Names});
  151.    }
  152.    function resetStage()
  153.    {
  154.       this._x = this.startPos.x;
  155.       this._y = this.startPos.y;
  156.    }
  157.    function lostLevel()
  158.    {
  159.       this.resetStage();
  160.       if(this.level > 1)
  161.       {
  162.          this.level -= 1;
  163.       }
  164.       else
  165.       {
  166.          this.level = 0;
  167.       }
  168.       _global.Footer.stopTimer();
  169.       _global.Footer.setTimer(180);
  170.       _global.Footer.setScore(0);
  171.       _global.Footer.setLives(3);
  172.       this.twinsArray = new Array();
  173.       this.upEscalators = new Array();
  174.       this.downEscalators = new Array();
  175.       this.randomTwinSpots = new Array();
  176.       this.randomPowerSpots = new Array();
  177.       this.randomBrokenSpots = new Array();
  178.       this.nextLevel();
  179.    }
  180.    function winLevel()
  181.    {
  182.       _global.Rescuer.resetPowerItems();
  183.       _global.Footer.stopTimer();
  184.       this.resetStage();
  185.       trace(this.level + " < " + this.MAX_LEVELS);
  186.       if(this.level < this.MAX_LEVELS)
  187.       {
  188.          this.gotoAndStop("next_level");
  189.       }
  190.       else
  191.       {
  192.          this.gotoAndStop("win");
  193.       }
  194.    }
  195. }
  196.